import request from "@/utils/request";
import type { PermissionListResponseData } from "../role/type";
import type { MenuData } from "./type";
enum API {
    GET_MENU_LIST = "/admin/acl/permission",
    ADD_CHILD_MENU = "/admin/acl/permission/save",
    UPDATE_MENU = "/admin/acl/permission/update",
    DELETE_MENU = "/admin/acl/permission/remove",
}

export const getMenuList = () => request.get<any, PermissionListResponseData>(API.GET_MENU_LIST)
export const AddorUpdateMenu = (data: MenuData) => {
    if (data.id) {
        return request.put<any, any>(API.UPDATE_MENU, data)
    } else {
        return request.post<any, any>(API.ADD_CHILD_MENU, data)
    }
}
export const DeleteMenu = (id: number) => request.delete<any, any>(API.DELETE_MENU + `/${id}`)
